import {createRouter, createWebHashHistory, createWebHistory, RouteRecordRaw} from 'vue-router';
import {routerMode} from '@/config/proj';
const NotFound = () => import('@/views/404.vue')
const constantRouters : RouteRecordRaw[] = [
  {
    path: '/404',
    name: '404',
    component: NotFound
  },
  {
    path: '/401',
    name: '401',
    component: () => import('@/views/401.vue')
  },
  {
    path: '/:pathMatch(.*)',
    redirect: '/404',
    component: NotFound
  }
]

let router = createRouter({
  history: routerMode === 'history' ? createWebHistory() : createWebHashHistory(),
  routes: constantRouters,
  scrollBehavior: () => ({
    top: 0
  })
})
export function resetRouter(): void {
  router = createRouter({
    history: routerMode === 'history' ? createWebHistory() : createWebHashHistory(),
    routes: constantRouters,
    scrollBehavior: () => ({
      top: 0
    })
  })
}
export default router
